package com.bjsxt.login.dao.impl;

import com.bjsxt.livegoods.pojo.ValidateCode;
import com.bjsxt.login.dao.RedisDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;

import java.time.Duration;

/**
 * @ClassName : RedisDaoImpl
 * @Description :
 * @Author : ZWZ
 * @Date: 2021/8/27 10:26
 */
@Repository
public class RedisDaoImpl implements RedisDao {

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public void set(String key, Object value) {
        redisTemplate.opsForValue().set(key, value, Duration.ofMinutes(2));
    }

    @Override
    public ValidateCode get(String key) {
        return (ValidateCode) redisTemplate.opsForValue().get(key);
    }

    @Override
    public void delete(String key) {
        redisTemplate.delete(key);
    }

}
